Skip to content

Latest commit

 

History

History
 
 

13 PyQt5 QListView

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

PyQt5 QListView

This example shows how you can use a PyQt5 QListView to display a list.

PyQt5 QListView

It simply shows a static list of strings. Technically, the data is managed by Qt's QStringListModel. The important steps of the code are:

model = QStringListModel(["An element", "Another element", "Yay! Another one."])
view = QListView()
view.setModel(model)
view.show()

This is very similar to the previous example, where we displayed a tree view of files. The reason for this similarity is that both examples use Qt's Model/View framework. As an exercise for yourself, you might want to try using QListView instead of QTreeView in the previous example.

To run this example, please follow the instructions in the README of this repository.